
#include <iostream>

#include "../core/typedefs.h"
#include "../core/constraints.h"
#include "../meshdef/deformationMesh.h"
//~ #include "../meshdef/deformationMesh_rbfguided.h"
#include "../meshdef/mesh.h"

using namespace std;

void print(const Number *pos, int n) {
   
   for (int i=0; i<n; ++i)
      cout<<" : "<<pos[i*3]<<" "<<pos[i*3+1]<<" "<<pos[i*3+2]<<endl;
}

void print(const Constraints *dcpos) {
   
   print(&dcpos->positions[0][0], dcpos->size());
}

int main() {
   
   // Load the model
   Mesh model("../data/cubeT.off");
   cout<<"model.nvertices(): "<<model.nvertices()<<endl;
   //~ for (unsigned iv=0; iv<model.nvertices(); ++iv) {
      //~ const float *p = &model.vpositions[iv*3];
      //~ const Point3 &p = 
      //~ cout<<p[0]<<" "<<p[1]<<" "<<p[2]<<endl;
   //~ }
   
   // Define the constraints
   //~ using MLS::Point3;
   Constraints constraints;
   constraints.push_back(Point3(1,1,1));
   constraints.push_back(Point3(1,1,-1));
   constraints.push_back(Point3(1,-1,1));
   cout<<"The initial constraints ..."<<endl;
   print(&constraints);
   
   // Instance a MLS-based mesh deformer
   DeformationMesh deformer(&model);
   deformer.setting(&constraints);
   
   // Specify a new constraint set
   Vector3 t(0.5,0.0,0.0);
   constraints.translate(0, t);
   cout<<"The deformed constraints ..."<<endl;
   print(&constraints);
   
   // Execute the deformation
   deformer.execute_deformation(&constraints);
   
   cout<<"Deformed vertex posiitons ..."<<endl;
   cout<<"model.nvertices(): "<<model.nvertices()<<endl;
   for (unsigned iv=0; iv<model.nvertices(); ++iv) {
      //~ const float *p = &model.vpositions[iv*3];
      //~ cout<<p[0]<<" "<<p[1]<<" "<<p[2]<<endl;
   }
   
   return 0;
}
